﻿<cfsilent>
	<cfscript>

		sessionAdvice = getProperty("serviceFactory").getBean("sessionAdvice");
		dictAdvice = getProperty("serviceFactory").getBean("senateDictionaryAdvice");
		pageAdvice = getProperty("serviceFactory").getBean("pageAdvice");

		teacherId = sessionAdvice.getAutherUserID();
		
		hashCode = event.getArg("Sign");
		taskId = event.getArg("TSK");
		taskType = event.getArg("TT");

		checked = false;
		

			if ( decrypt(hashCode, teacherId, "PBEWithMD5AndDES", "Hex") eq taskId ) {

				/* 载入期末成绩提交任务 */

				sql = "	SELECT 
							tm.task_id, tm.mark_need, 
							tm.mark_done,c.mark_mode,tm.task_prog, c.prop_id 
						FROM t_task_mark tm
							INNER JOIN t_course c ON c.cid = tm.cid
						WHERE
							tm.task_id = :taskId ";
							
				queryObj = new Query(datasource = application.dnsSlave);
				
				queryObj.addParam(name="taskId", value=taskId, cfsqltype="cf_sql_varchar");
				
				rs_task = queryObj.execute(sql=sql).getResult();
				
				
				progress = 0;
					
				if ( rs_task.mark_need ) {
					progress = int( rs_task.mark_done * 10000 / rs_task.mark_need ) / 100;
				}

				/* 生成分页 */
				pageAdvice.setTotleRow( rs_task.mark_need );
				pageAdvice.setStartRow( event.getArg("Start", 1) );
				pageAdvice.setPage( event.getArg("Page", 1) );
				
				pageAdvice.setRowPerPage( 60 );
				
				pageArray = pageAdvice.getPageList();

				if ( rs_task.mark_mode eq "0" and ( rs_task.task_prog eq "1" or rs_task.task_prog eq "2" ) ) {

					checked = true;
					
					/* 更新成绩提交状态 */
					transaction {
						sql = "	UPDATE t_task_mark t
								SET 
									t.task_prog = :taskProgress 
								WHERE
									t.task_id = :taskId ";
									
						updateObj = new Query(datasource = application.dnsMaster);
						
						updateObj.addParam(name="taskId", value=taskId, cfsqltype="cf_sql_varchar");
						updateObj.addParam(name="taskProgress", value="2", cfsqltype="cf_sql_char");
						
						updateObj.execute(sql=sql);

					}
					
					/* 传递参数处理 */
					pageArgs = structNew();
					structInsert( pageArgs, "TSK", taskId, true );
					structInsert( pageArgs, "TT", taskType, true );
					structInsert( pageArgs, "Sign", encrypt(taskId, teacherId, "PBEWithMD5AndDES", "Hex"), true );

					targetArgs = structNew();
					structInsert( targetArgs, "TSK", taskId, true );
					structInsert( targetArgs, "TT", taskType, true );
					structInsert( targetArgs, "Sign", encrypt(taskId, teacherId, "PBEWithMD5AndDES", "Hex"), true );

					/* 载入成绩提交名单 */
					
					sql = "	SELECT tmm.scc_id,
									tmm.stu_id,
									stu.stu_name,
									tmm.st,
									tmm.mark_u,
									tmm.mark_m, 
									tmm.mark_f,
									tmm.mark_note
								 FROM t_temp_mark tmm
									 INNER JOIN t_student stu ON stu.stu_id = tmm.stu_id
								 WHERE tmm.task_id = :taskId 
								 ORDER BY tmm.stu_id";

					queryObj = new Query(datasource = application.dnsSlave);
					
					queryObj.addParam(name="taskId", value=taskId, cfsqltype="cf_sql_varchar");
					
					rs_student = queryObj.execute(sql = sql).getResult();

					startRow = pageAdvice.getStartRow();
					endRow = startRow + pageAdvice.getRowPerPage() - 1;

				}
				
			}

		/* 判断当前显示课表内容 */
		currentTab = event.getArg("TabID", "labSheet");
	
	</cfscript>
</cfsilent>

<cfif checked >
	
		<div class="UItab">
			<div class="tabLables">
				<span <cfif currentTab eq "labSheet">class="active"</cfif> id="labSheet" tabTarget="Sheet">录入成绩核查</span>
			</div>
		</div>
		<script language="javascript" type="text/javascript">
			//<![CDATA[
			<!--
			$(document).ready(function() {
						
				/* init Tab */
				$("div.tabContent").hide();
				$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
				
				$("div.tabLables > span").click(function(){
					var $targetID = $(this).attr("tabTarget");
						
					$("div.tabLables span").removeClass("active");
					$(this).addClass("active");
							
					$("div.tabContent").not('[id="' + $targetID + '"]').hide();
					$("div.tabContent#" + $targetID).show();
				});
						
			});
			// -->
			//]]>
		</script>

		<div id="Sheet" class="tabContent">
			
			<div class="noticeBlock">
				<h3>课程考核成绩</h3>
				<p>
					<span class="img icon16x16 message"></span>
					请注意, 这里需要提交的是课程考核成绩. 当前课程成绩按照百分制提交, 课程考核分数应当填写为 <em>0-100</em> 之间的数字. 同时请注意缺考和缓考标注.
				</p>
				<hr/>
			</div>
			
			<cfif progress eq 100>
			
				<!--- 如果计分完成, 则显示跳转到成绩检查页面 --->
				<div id="complateNotice" class="systemNotice">
					<h3><span class="img icon16x16 info"></span>成绩核对</h3>
					<p>注意: 您需要在学校规定的时间内完成教学任务的成绩提交. </p>
					<p>请在正式提交成绩之前, 仔细核对录入成绩是否完全正确. 成绩一旦正式提交, 将不可再次更改. </p>
					<form id="formRemove" class="formWrapper Transparent" method="post" action="<cfoutput>#buildURL('taskMarkWizardSubmit')#</cfoutput>">
						<input type="hidden" name="TSK" value="<cfoutput>#taskId#</cfoutput>" />
						<input type="hidden" name="TT" value="<cfoutput>#taskType#</cfoutput>" />
						<input type="hidden" name="Sign" value="<cfoutput>#encrypt(taskId, teacherId, 'PBEWithMD5AndDES', 'Hex')#</cfoutput>" />
						<div class="lable"><input class="button2" type="submit" value="正式提交成绩" /></div>
					</form>
				</div>
			
			
			
				<table class="UIEditable">
					<thead>
						<tr>
							<td width="30"></td>
							<td>学号</td>
							<td>姓名</td>
							<td width="200">修读方式</td>
							<td width="50">平时</td>
                                   <cfif rs_task.prop_id eq '1'><td width="50">期中</td></cfif>
                                   <td width="50">期末</td>
							<td width="25"></td>
						</tr>
					</thead>
					<tbody>
					
						<cfset row = pageAdvice.getOffset() />
                        <cfloop startrow="#startRow#" endrow="#endRow#" query="rs_student">
						
							<cfset row++ />
							<cfset structInsert( targetArgs, "Start", pageAdvice.getStartRow(), true ) />
							<cfset structInsert( targetArgs, "Page", pageAdvice.getPage(), true ) />
							<cfset structInsert( targetArgs, "Target", rs_student.scc_id, true ) />
						
							<tr class="editRows studyType<cfoutput>#rs_student.st#</cfoutput>">
							
								<td class="index"><cfoutput>#row#</cfoutput></td>
								<td><span class="numeric"><cfoutput>#rs_student.stu_id#</cfoutput></span></td>
								<td><cfoutput>#rs_student.stu_name#</cfoutput></td>
								<td><cfoutput>#dictAdvice.getStudyType( rs_student.st )#</cfoutput></td>
								
                                        <cfif rs_student.mark_note eq "2">
                                        		<td colspan="3" align="center"><span class="markNote<cfoutput>#rs_student.mark_note#</cfoutput>">---- 缺考 ----</span> </td>
                                             <cfelseif rs_student.mark_note eq "3">
                                             	<td colspan="3" align="center"><span class="markNote<cfoutput>#rs_student.mark_note#</cfoutput>">---- 缓考 ----</span> </td>
                                        	<cfelse>
                                             	<td>
										<span class="numeric <cfif rs_student.mark_u lt 60>markNote0</cfif>"><cfoutput>#numberFormat(rs_student.mark_u, '_._')#</cfoutput></span> </td>
										<!---<cfelseif rs_student.mark_note eq "3">
										<span class="markNote<cfoutput>#rs_student.mark_note#</cfoutput>">缓考</span>
										<cfelseif rs_student.mark_note eq "9">
										<span class="markNote<cfoutput>#rs_student.mark_note#</cfoutput>">违纪</span>--->
									
                                             	
										<cfif rs_task.prop_id eq '1'>
                                                       <td>
                                                       <span class="numeric <cfif rs_student.mark_m lt 60>markNote0</cfif>"><cfoutput>#numberFormat(rs_student.mark_m, '_._')#</cfoutput></span></td>
                                                 	</cfif>
                                                   <td>
                                                 
                                                            <span class="numeric <cfif rs_student.mark_f lt 60>markNote0</cfif>"><cfoutput>#numberFormat(rs_student.mark_f, '_._')#</cfoutput></span>
                                                            
                                                  </td>
									
                                        </cfif>
								
                                      
                                        
                                       
							
								<td><a href="<cfoutput>#buildURL('taskMarkWizardMode0', targetArgs)#</cfoutput>" class="stat operation"></a></td>
							
							</tr>
						</cfloop>
					
					</tbody>
				</table>
			
				<div class="pagination">
					<div class="summary">Page:<cfoutput>#pageAdvice.getPage()#</cfoutput>/<cfoutput>#pageAdvice.getPageCount()#</cfoutput> Totle:<cfoutput>#pageAdvice.getTotleRow()#</cfoutput></div>
					<div class="lists">
						<cfloop from="1" to="#arrayLen(pageArray)#" index="page">

							<cfset structInsert( pageArgs, "Start", pageArray[page][2], true ) />
							<cfset structInsert( pageArgs, "Page", pageArray[page][3], true ) />

							<cfswitch expression="#pageArray[page][1]#">
								<cfcase value="D">
									<a href="<cfoutput>#buildURL(event.getName(), pageArgs)#</cfoutput>"><cfoutput>#pageArray[page][3]#</cfoutput></a>
								</cfcase>
								<cfcase value="C">
									<span><cfoutput>#pageArray[page][3]#</cfoutput></span>
								</cfcase>
								<cfcase value="F">
									<a href="<cfoutput>#buildURL(event.getName(), pageArgs)#</cfoutput>">First</a>
								</cfcase>
								<cfcase value="P">
									<a href="<cfoutput>#buildURL(event.getName(), pageArgs)#</cfoutput>">Previous</a>
								</cfcase>
								<cfcase value="N">
									<a href="<cfoutput>#buildURL(event.getName(), pageArgs)#</cfoutput>">Next</a>
								</cfcase>
								<cfcase value="L">
									<a href="<cfoutput>#buildURL(event.getName(), pageArgs)#</cfoutput>">Last</a>
								</cfcase>
							</cfswitch>
						</cfloop>
					</div>
				</div>
			
				<cfelse>
			
				<div class="systemNotice">
					<p>您尚未完成成绩录入</p>
					<ol>
						<li>请完成全部课程成绩录入后再重新进行成绩检查, <a href="<cfoutput>#buildURL('taskMarkWizardMode0', targetArgs)#</cfoutput>">继续进行成绩录入</a></li>
					</ol>
				</div>
			
			</cfif>
			
		</div>
		
	<cfelse>
	
		<div class="systemNotice">
			<h3><span class="img icon16x16 message"></span>错误的参数</h3>
			<p>请关闭浏览器重新登录 或 检查您是否使用了正确访问方式</p>
		</div>
</cfif>

